var e, t, i = require("../../utils/util.js"), a = getApp().globalData.url.imgurl;

Page({
    data: {
        imgurl: a
    },
    onLoad: function(a) {
        t = this, i.getToken(function(a) {
            e = a, i.sendrequest("posterapi/userinfo", "POST", {
                token: a
            }, function(e) {
                1 == e.status && t.setData({
                    info: e.data,
                    weixin_code: e.data.weixin_code
                });
            });
        });
    },
    onShow: function() {
        try {
            var a = wx.getStorageSync("cutpath"), o = wx.getStorageSync("cutindex");
        } catch (e) {}
        a && "weixincode" == o && (wx.removeStorageSync("cutpath"), wx.removeStorageSync("cutindex"), 
        wx.showLoading({
            title: "上传中"
        }), i.upload("posterapi/upload_weixin_code", a, "weixin_code", {
            token: e
        }, function(e) {
            wx.hideLoading();
            t.data.info;
            t.setData({
                weixin_code: e.data.path
            });
        }));
    },
    submit: function(e) {
        var t = e.detail.value;
        t.formid = e.detail.formId, i.getToken(function(e) {
            t.token = e, wx.showLoading({
                title: "提交中",
                mask: !0
            }), i.sendrequest("posterapi/updateinfo", "POST", t, function(e) {
                wx.hideLoading(), 1 == e.status && (wx.showToast({
                    title: "已保存"
                }), setTimeout(function() {
                    wx.navigateBack({
                        delta: 1
                    });
                }, 2e3));
            });
        });
    },
    uploadcode: function(e) {
        wx.chooseImage({
            count: 1,
            sizeType: [ "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(e) {
                wx.navigateTo({
                    url: "/pages/image/image?width=100&height=100&cutindex=weixincode&path=" + e.tempFilePaths[0]
                });
            }
        });
    }
});